
\documentclass{beamer}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}

\usepackage{beamerthemesplit}
\usepackage{hyperref}

\title{Artificial Opponent in Real Time Strategy games using Agents}
\author{Toni Cebrián \and Xavi Pérez}
\date{\today}

\begin{document}
% Descomentar cuando se quiera generar la versión con las notas
%\setbeameroption{show notes}
%\setbeameroption{notes on second screen}

%Intro
%    - Problema
%    - Solución 
%    - Implementación
%Jason
%    - Pq? 
%        - Expresividad
%        - Documentacion
%Prometheus
%    - Decisiones de diseño
%    - Scenario
%    - Tools
%    - Problemas
%
%Sensing
%    - Events
%    - Callbacks
%    - Commands
%    - Translation
%        - Actions
%        - Percepts (commands y callbacks)

\frame{
\titlepage
}
\frame{
\tableofcontents
}

\section{Introduction}
\begin{frame}
    \frametitle{Introduction}
    \begin{itemize}
		\item {\bf Problem to solve}
            \begin{itemize}
                \item Artificial opponent for SpringRTS
            \end{itemize}
		\item {\bf Solution}
            \begin{itemize}
                \item Multi-Agent System
            \end{itemize}
		\item {\bf Implementation}
            \begin{itemize}
                \item Percepts
                \item Actions
                \item Plans
			\end{itemize}
    \end{itemize}

\note{
% Problem \& solution:
In this work we have tried to build an artificial opponent able to play the game
Real Time Strategy Game SpringRTS. We have chosen to build that artificial
opponent using a Multi-Agent System.
% Implementation:
In order to accomplish that we have to build:
- the sensing framework
- percepts and actions to be performed against the platform
- and finally we should try to create some plans for our agent. 

For the interfacing phase, we have developed the Java classes for transforming
the raw low-level actions and percepts into Java objects that can be sent to the
Jason platform. 

When developing any software system an important issue is always to obtain
guidance from a methodology that can ease the burden of the development process.

In particular we have chosen the Prometheus methodology for designing and
specifying our system.
}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Prometheus}
\begin{frame}
    \frametitle{System's mission}
    \begin{quote}
        We want a system able to play the game of SpringRTS. It will be able to
        control the Commander to create buildings. Some of those buildings in
        turn will be able to create a limited set of units that will be used to
        attack the enemy player. We need to gather resources to build more units
        or buildings. We also want to implement communication between team
        members.
    \end{quote}
\end{frame}
\begin{frame}
    \frametitle{Goals}
    \begin{columns}
        \begin{column}{.4\textwidth}
            Functionalities 
            \begin{itemize}
                \item Movement 
                \item Construction
                \item Attacking
                \item Communication
            \end{itemize}
        \end{column}
        \begin{column}{.7\textwidth}
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[width=\textwidth]{images/GoalOverviewDiagram.png}
                \end{center}
            \end{figure}
        \end{column}
    \end{columns}
\end{frame}
\begin{frame}
    \frametitle{Design decisions}
    \begin{columns}
        \begin{column}{.4\textwidth}
            \begin{itemize}
                \item Five agents
                    \begin{itemize}
                        \item General
                        \item Military
                        \item Econ
                        \item Movement
                        \item Communications
                    \end{itemize}
            \end{itemize}
        \end{column}
        \begin{column}{.7\textwidth}
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[width=\textwidth]{images/Agents}
                \end{center}
            \end{figure}
        \end{column}
    \end{columns}
\end{frame}

\begin{frame}
    \frametitle{Scenario}
    \framesubtitle{Search for the enemy commander}
    \begin{columns}
        \begin{column}{.7\textwidth}
            \begin{enumerate}
                \item The General realises that he doesn't know where the Enemy
                    Commander is.
                \item The General sends a message to the Econ Agent to build three tanks
                \item The Econ checks whether he is able to build the tanks, if not he
                    builds the necessary buildings and builds the units.
                \item The Econ notifies when units are ready
                \item The General assigns the units to the military and issues the order
                    explore to the agent
            \end{enumerate}
        \end{column}
        \begin{column}{.3\textwidth}
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[width=\textwidth]{images/Proceso.png}
                \end{center}
            \end{figure}
        \end{column}
    \end{columns}
\end{frame}

\begin{frame}
    \frametitle{Analysis Overview Diagram}
    \begin{figure}[htp]
        \begin{center}
            \includegraphics[width=\textwidth]{images/AnalysisOverviewDiagram.png}
        \end{center}
    \end{figure}
\end{frame}

\begin{frame}
    \frametitle{Artifacts}
    \begin{center}
        \textbf{``Show Design Document''}
    \end{center}
\end{frame}

\begin{frame}
    \frametitle{Tools \& Documentation}
    \begin{columns}
        \begin{column}{.6\textwidth}
            \begin{center}
                Design tool
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[width=\textwidth]{images/PDT.png}
                \end{center}
            \end{figure}
            \end{center}
        \end{column}
        \begin{column}{.4\textwidth}
            \begin{center}
                Reference: 
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[height=6cm]{images/Book.png}
                \end{center}
            \end{figure}
            \end{center}
        \end{column}
    \end{columns}
\end{frame}

\begin{frame}
    \frametitle{Impressions}
    \begin{itemize}
        \item Pros:
            \begin{enumerate}
                \item Helpful guidelines
                \item Well defined stages
            \end{enumerate}
        \item Cons:
            \begin{enumerate}
                \item Very heavy weight methodology
                \item Tool availability misleading and sometimes hard to use
                \item Some artifacts were of no use to us
            \end{enumerate}
    \end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Jason}
\begin{frame}
    \frametitle{Why we chose Jason in the first place?}
    \begin{columns}
        \begin{column}{.6\textwidth}
            Two main reasons:
            \begin{itemize}
                \item It has available and high quality documentation
                \item The BDI model implemented in it seemed adequate to our purposes
                \item Other projects with aims similar to ours were developed with Jason
            \end{itemize}
        \end{column}
        \begin{column}{.4\textwidth}
            \begin{figure}[htp]
                \begin{center}
                    \includegraphics[height=5cm]{images/JasonBook.png}
                \end{center}
            \end{figure}
        \end{column}
    \end{columns}
\end{frame}

\begin{frame}
    \frametitle{Correspondence with the Jason model}
    \begin{itemize}
        \item There is a plan triggered by the belief \texttt{~position(EC)}
        \item There is a communication established between the General and the
            Econ \texttt{.send(BuildTanks)}
        \item The Econ fires a \emph{test plan} to check whether he has the
            buildings
        \item Depending on the check he fires the plan of building the needed
            buildings, and after that the plan of building units.
        \item There are new \textbf{Percepts} about some units created
        \item The General sends to the Military the order of Exploring a
            specified region
        \item The Military issue the order of moving
        \item Whenever the Percept \emph{Enemy Commander enters the LOS} is
            received this plan ends.
    \end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Sensing}

\begin{frame}
	\frametitle{World Interaction}
	\framesubtitle{Events}
	{\it commandFinished, enemyDamaged, enemyDestroyed, enemyEnterLOS,
	enemyEnterRadar, enemyLeaveLOS, enemyLeaveRadar, message, unitCaptured,
	unitCreated, unitDamaged, unitDestroyed, unitFinished, unitGiven, unitIdle,
	unMoveFailed, weaponFired, seismicPing}
\note{
%Intro:
Everything remarkable in SpringRTS is an event. Whenever an enemy unit is
spotted, a new unit is created or a building finished, for example, SpringRTS
notifies the AI with a new event.

Those events are sent through a Java interface and should be captured by our AI
module.

There are ..., ... and ...

Now is not important to know what are these events, you only have to know the
idea that there are events for all situations.
}
\end{frame}

\begin{frame}
	\frametitle{World Interaction}
	\framesubtitle{Callbacks}
	\begin{itemize}
		\item {\bf Economy, map and units}
			\begin{itemize}
				\item getEconomy(), getResources, getMap(), getMod(),
					getFeatures(), getUnits(), getUnitDefs()\ldots
			\end{itemize}
	\end{itemize}
	\begin{itemize}
		\item {\bf Visibility}
			\begin{itemize}
				\item getEnemyUnitsInRadarAndLos(), getEnemyUnits(),
					getNeutralUnits(),
			\end{itemize}
	\end{itemize}
	\begin{itemize}
		\item {\bf getEngine()}
			\begin{itemize}
				\item getEngine().handleCommand
			\end{itemize}
	\end{itemize}
\note{
%Intro:
Callbacks are the channel through which our module communicates with the
SpringRTS Platform when requesting actions.

There is a callback object that holds the reference for this communicating
channel, and provides several methods that allows the agent to call the platform
for specific information.

The methods used in this work are:

%Items:
% ---
Static information, getUnits and
getEconomy(): Give us information about resources available in the map.
% ---
getEnemyUnits(): Returns all enemy units that are in Line Of Sight (LOS)

getEnemyUnitsInRadarAndLos(): Returns all enemies that are in radar
% ---
And getEngine(), that deserves a whole section for itself, because returns an
object that allow to handle commands to the Spring engine.
}
\end{frame}

\begin{frame}
	\frametitle{World Interaction}
	\framesubtitle{Commands}
	\begin{itemize}
		\item {\bf Attack:} AttackUnitAICommand
		\item {\bf Build:} BuildUnitAICommand
		\item {\bf Move:} MoveUnitAICommand
	\end{itemize}

\note{
%Intro:
To change the world in SpringRTS we have to send commands to the platform
through a Callback object.

SpringRTS has a huge number of AICommands to achieve diverse actions; from path
setting commands or adding units to groups, until draw figures in the screen.

The commands used in this work are:

%Items:
AttackUnitAICommand: This object packs the unit we want to give the
					order to attack and the target unit.
BuildUnitAICommand: This object packs the unit we want to give the
					order to build, the construction definition, the building
					point and the orientation.
MoveUnitAICommand: This object packs the unit we want to give the order
					to move and the destination point.

}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\frametitle{GUI}
	\begin{figure}[htp]
	\begin{center}
		\includegraphics[width=10cm]{images/GUIboss.png}
	\end{center}
	\label{fig:GUIbossEvents}
\end{figure}
\end{frame}

\note{
Except for Getting Started manuals, useful at first steps of project creation,
we did not find documentation about internal running of the wrappers.

Therefore, we had to learn about the platform in an inductive way. This was done
implementing a GUI to command our Spring Agent.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\frametitle{Translation}
\note{
% Intro:
In the translation section, I will explain you the equivalences between ``Spring
world'' and Jason reasoning.
}
\end{frame}

\begin{frame}
	\frametitle{Translation}
	\framesubtitle{From events to percepts}
	\begin{table}[htp]
	\centering
	\begin{tabular}{ c c c }
		{\bf SpringRTS event} &  & {\bf Jason percept}\\
		\hline
		UnitFinished & $\longrightarrow$ &
		Game Starts \\
	
		enemyEnterLOS  &
		$\longrightarrow$ & Enemy Commander in Los \\
	
		UnitFinished &
		$\longrightarrow$ & Order of units Constructed \\
	\end{tabular}
\end{table}
\note{
% Intro:
First of all, we have to define to ways of generate percepts from SpringRTS to
Jason.

On one hand, each time a relevant event is sent by Spring Engine, it is
caught and treated to be useful for Jason.

On the other hand, when Jason needs some information about the environment and
makes the question in a callback form, the answer must be converted, too, in a
Jason percept.

%Items:
The events caught relevant for this work are:


Game Starts comes from UnitFinished event:
	This is because we have considered that game starts when Java module takes
	the control of Spring commander, and this occurs when the commander unit of
	our team is created, i.e. when is received the UnitFinished event with the
	reference to our commander.

}
\end{frame}

\begin{frame}
	\frametitle{Translation}
	\framesubtitle{From callbacks to percepts}
	\begin{table}[htp]
	\centering
	\begin{tabular}{ c c c }
		{\bf Callback method}&  & {\bf Jason percept}\\
		\hline
		getMap() & $\longrightarrow$ &
		Measures of Map \\
		
		commander.getPos()  &
		$\longrightarrow$ & Commander Position \\
			
		getEconomy() &  $\longrightarrow$
		& Metal Available \\

		getEconomy()  &
		$\longrightarrow$ & Energy Available \\
				
		getUnitDefs() & $\longrightarrow$ &
		Unit Metal Cost \\

		getUnitDefs() & $\longrightarrow$ &
		Unit Energy Cost \\
		
		getUnitDefs()& $\longrightarrow$ &
		Unit Tech Dependence \\
		\end{tabular}
	\label{tab:Callbacks2Percepts}
\end{table}
\note{
%Intro:
To comlete the percepts' origin, these are the callbacks useful for our problem:

%Items:
most of them come from getEconomy end getUnitsDef
	because these are, respectively, the generic methods that return information
	about all the parameters related with resources and units in the game.


}
\end{frame}

\begin{frame}
	\frametitle{Translation}
	\framesubtitle{Form actions to commands}
	\begin{table}
	\begin{tabular}{ c c c }
		{\bf Jason action} &  & {\bf Spring AI Command}\\
		\hline
		Attack Unit & $\longrightarrow$ &
		AttackUnitAICommand \\

		Create Building  &
		$\longrightarrow$ & BuildUnitAICommand \\

		Create Unit&  $\longrightarrow$ &
		BuildUnitAICommand \\

		Move Unit & $\longrightarrow$ &
		MoveUnitAICommand \\
	\end{tabular}
\end{table}
\note{
% Intro:
Unlike the allocations specified in the previous section, these equivalences are
almost straightforward and easy to understand.

}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\frametitle{Questions?}
\end{frame}

\end{document}
